/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tkatva.soalog.SoalogEjb.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author tuomas
 */
@Entity
@Table(name = "log_entry")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "LogEntry.findAll", query = "SELECT l FROM LogEntry l")})
public class LogEntry implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "log_entry_id")
    private Integer logEntryId;
    @Size(max = 200)
    @Column(name = "integration_instance_id")
    private String integrationInstanceId;
    @Size(max = 200)
    @Column(name = "instance_version")
    private String instanceVersion;
    @Column(name = "log_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date logDate;
    @Size(max = 45)
    @Column(name = "log_level")
    private String logLevel;
    @Size(max = 1000)
    @Column(name = "log_msg")
    private String logMsg;
    @Size(max = 40000)
    @Column(name = "log_payload")
    private String logPayload;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "logEntryId")
    private List<EntryValues> entryValuesList;
    @JoinColumn(name = "log_interface_id", referencedColumnName = "log_interface_id")
    @ManyToOne(optional = false)
    private LogInterface logInterfaceId;

    public LogEntry() {
    }

    public LogEntry(Integer logEntryId) {
        this.logEntryId = logEntryId;
    }

    public Integer getLogEntryId() {
        return logEntryId;
    }

    public void setLogEntryId(Integer logEntryId) {
        this.logEntryId = logEntryId;
    }

    public String getIntegrationInstanceId() {
        return integrationInstanceId;
    }

    public void setIntegrationInstanceId(String integrationInstanceId) {
        this.integrationInstanceId = integrationInstanceId;
    }

    public String getInstanceVersion() {
        return instanceVersion;
    }

    public void setInstanceVersion(String instanceVersion) {
        this.instanceVersion = instanceVersion;
    }

    public Date getLogDate() {
        return logDate;
    }

    public void setLogDate(Date logDate) {
        this.logDate = logDate;
    }

    public String getLogLevel() {
        return logLevel;
    }

    public void setLogLevel(String logLevel) {
        this.logLevel = logLevel;
    }

    public String getLogMsg() {
        return logMsg;
    }

    public void setLogMsg(String logMsg) {
        this.logMsg = logMsg;
    }

    public String getLogPayload() {
        return logPayload;
    }

    public void setLogPayload(String logPayload) {
        this.logPayload = logPayload;
    }

    @XmlTransient
    public List<EntryValues> getEntryValuesList() {
        return entryValuesList;
    }

    public void setEntryValuesList(List<EntryValues> entryValuesList) {
        this.entryValuesList = entryValuesList;
    }

    public LogInterface getLogInterfaceId() {
        return logInterfaceId;
    }

    public void setLogInterfaceId(LogInterface logInterfaceId) {
        this.logInterfaceId = logInterfaceId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (logEntryId != null ? logEntryId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof LogEntry)) {
            return false;
        }
        LogEntry other = (LogEntry) object;
        if ((this.logEntryId == null && other.logEntryId != null) || (this.logEntryId != null && !this.logEntryId.equals(other.logEntryId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "tkatva.soalog.SoalogEjb.entities.LogEntry[ logEntryId=" + logEntryId + " ]";
    }
    
}
